﻿using System;

using System.Windows .Forms ;
using DevExpress.XtraEditors;
using LayerData;
using LayerLogic.Common ;
using LayerLogic.Hotel;
using LayerLogic.Producto;
using LayerLogic.Persona ;
using LayerLogic.Almacen;
using LayerLogic.Caja;
using LayerLogic.Ventas;
using LayerLogic.Creditos;

namespace System2012
{
    class SystemUtils
    {
        public static void ShowMessaje(string mensaje, MessageBoxButtons button, MessageBoxIcon icon)
        {
            XtraMessageBox.Show(mensaje, ProductInfo.Product ); 
        }
        public static void AlerMessaje(string msj) {
            XtraMessageBox.Show(msj, ProductInfo.Product, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        public static void InformationMessaje(string msj)
        {
            XtraMessageBox.Show(msj, ProductInfo.Product, MessageBoxButtons.OK, MessageBoxIcon.Information );
        }
        public static DialogResult Question(string msj, string strTitle) {
            return XtraMessageBox.Show(msj, strTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public static Form SetParams(Form f,MdiClient mdi) {
            f.WindowState = FormWindowState.Maximized;
            //f.Size = new System.Drawing.Size(mdi.Size.Width, mdi.Size.Height);
            //f.Location = new System.Drawing.Point(mdi.Location.X, mdi.Location.Y);
            return f;
        }

        public static void Exportar(string fileName, DevExpress.XtraGrid.GridControl g) {
            System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
            sfd.DefaultExt = "xlsx";
            sfd.FileName = fileName;
            sfd.Filter = "Excel 2007 (*.xlsx)|*.xlsx|Excel 97-2003(*.xls)|*.xls";
            sfd.FilterIndex = 0;
            sfd.RestoreDirectory = true;
            sfd.Title = "Exportar Informacion";
            if (sfd.ShowDialog() == DialogResult.OK) {
                if (System.IO.Path.GetExtension(sfd.FileName) == ".xls")
                {
                    g.ExportToXls(sfd.FileName);
                }
                else {
                    g.ExportToXlsx(sfd.FileName);
                }
            }
        }

        public static void SendNextControl(Control c,bool back) {
            if (back)
            {
                c.SendToBack();
            }
            else
            {
                SendKeys.Send("{TAB}");
            }
        }

        #region Variables Publicas y Seteos

        static CommonObjects recordManagerObj = null;
        static CommonMaintenance commonMantenanceObj = null;
        static LHotel RecodManajerHotelObj = null;
        static LProducto RecodManajerProductoObj = null;
        static LHabitacion MantenanceHabitacionObj = null;
        static LPersona recordMangerPersona=null;
        static LAlmacen recordmanagerAlmacn = null;
        static LCaja recordmanagerCaja = null;
        static LFacturacion recordManagerFacturacion = null;
        static LCreditos recordManagerCreditos = null;
        public static LHabitacion MantenanceHabitacion
        {
            get
            {
                return MantenanceHabitacionObj;
            }
        }
        public static CommonObjects RecordManagerCommonList
        {
            get
            {
                return recordManagerObj;
            }
        }

        public static CommonMaintenance CommonMaintenanceList {
            get {
                return commonMantenanceObj;
            }
        }
        public static LHotel RecodManajerHotel
        {
            get
            {
                return RecodManajerHotelObj;
            }
        }

        public static LProducto RecodManajerproducto
        {
            get
            {
                return RecodManajerProductoObj;
            }
        }
        public static LAlmacen RecordmanagerAlmacen
        {
            get {
                return recordmanagerAlmacn;
            }
        }
        public static LCaja RecordmanagerCaja
        {
            get
            {
                return recordmanagerCaja;
            }
        }

        public static LFacturacion RecordManagerFacturacion
        {
            get
            {
                return recordManagerFacturacion;
            }
        }
        public static LCreditos RecordManagerCreditos
        {
            get
            {
                return  recordManagerCreditos;
            }
        }
        public void InicializarVariables(IPostgreSqlConnectionInfo connectionInfo)
        {
            recordManagerObj = new CommonObjects(connectionInfo);
            commonMantenanceObj = new CommonMaintenance(connectionInfo);
            RecodManajerHotelObj = new LHotel(connectionInfo);
            RecodManajerProductoObj = new LProducto(connectionInfo);
            MantenanceHabitacionObj = new LHabitacion(connectionInfo);
            recordMangerPersona = new LPersona ( connectionInfo );
            recordmanagerAlmacn = new LAlmacen(connectionInfo);
            recordmanagerCaja = new LCaja(connectionInfo);
            recordManagerFacturacion = new LFacturacion(connectionInfo);
            recordManagerCreditos = new LCreditos(connectionInfo);
        }

        public static LPersona RecordManagerPersona {
            get {
                return recordMangerPersona;
            }
        }
        public static  IPostgreSqlConnectionInfo CurrentConnection { get; set; }
        #endregion
    }
}